package com.huabo.contract.mysql.mapper;

import com.hbfk.util.PageInfo;
import com.huabo.contract.mysql.entity.TblLegalNegotiatedsettlemenMySql;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author huabo
 * @since 2022-03-17
 */
public interface TblLegalNegotiatedsettlemenMySqlMapper extends BaseMapper<TblLegalNegotiatedsettlemenMySql> {

    @SelectProvider(type=TblLegalNegotiatedsettlemenMySqlMapperSqlConfig.class,method="findListByPage")
    List<TblLegalNegotiatedsettlemenMySql> findListByPage(PageInfo<TblLegalNegotiatedsettlemenMySql> pageInfo, TblLegalNegotiatedsettlemenMySql negotia, BigDecimal pid,Integer disputeid);

    @SelectProvider(type=TblLegalNegotiatedsettlemenMySqlMapperSqlConfig.class,method="findListByPageCount")
    Integer findListByPageCount(TblLegalNegotiatedsettlemenMySql negotia, BigDecimal pid,Integer disputeid);


    @Select("SELECT * FROM TBL_LEGAL_NEGOTIATEDSETTLEMEN tln\n" +
            "LEFT JOIN TBL_LEGAL_DISPUTREGISTRATION tld on tln.DISPUINFO = tld.DISPUTEID\n" +
            "LEFT JOIN TBL_CYHW_UNIT tcu on tld.CONTRACTINFO = tcu.CONTRACTID\n" +
            "LEFT JOIN  TBL_STAFF TCS ON TCS.STAFFID = tcu.CONTRACTSTAFF\n" +
            "WHERE tln.NEGOTIAID = #{negotiaId}")
    TblLegalNegotiatedsettlemenMySql findByNegotiaId(Integer negotiaId);

    @InsertProvider(type=TblLegalNegotiatedsettlemenMySqlMapperSqlConfig.class,method="saveDiputregistration")
    @Options(useGeneratedKeys=true, keyProperty="negotiaid", keyColumn="NEGOTIAID")
    void saveDiputregistration(TblLegalNegotiatedsettlemenMySql negotiated);

    @Delete("DELETE FROM TBL_LEGAL_NEGOTIATEDSETTLEMEN WHERE NEGOTIAID = #{negotiated}")
    void removeLegalNegotiatedSettlemen(Integer negotiated);

    @Delete("DELETE FROM TBL_LEGAL_NEGOTIATEDSETTLEMEN WHERE NEGOTIAID = #{recordId}")
    void removeNegitiateRecord(Integer recordId);

    @UpdateProvider(type=TblLegalNegotiatedsettlemenMySqlMapperSqlConfig.class,method="updateOldNegotiated")
    void updateOldNegotiated(TblLegalNegotiatedsettlemenMySql oldNegotiated);

    @SelectProvider(type=TblLegalNegotiatedsettlemenMySqlMapperSqlConfig.class,method="findListForLitiationList")
    List<TblLegalNegotiatedsettlemenMySql> findListForLitiationList(PageInfo<TblLegalNegotiatedsettlemenMySql> pageInfo, TblLegalNegotiatedsettlemenMySql negotiate);

    @SelectProvider(type=TblLegalNegotiatedsettlemenMySqlMapperSqlConfig.class,method="findListForLitiationListCount")
    Integer findListForLitiationListCount(TblLegalNegotiatedsettlemenMySql negotiate);

//    @Select("SELECT * FROM TBL_LEGAL_NEGOTIATERECORD TLN\n" +
//            "LEFT JOIN TBL_LEGAL_NEGOTIATEDSETTLEMEN TLE ON TLN.NEGOTIATEINFO = NEGOTIAID\n" +
//            "WHERE TLN.RECORDID = #{negotiaId}")
//    TblLegalNegotiatedsettlemen findNegotiaId(Integer negotiaId);
}
